package com.example.demo.school.repositories;

import com.example.demo.school.models.StStudent;
import com.example.demo.school.models.StType;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface StStudentRepository extends JpaRepository<StStudent, Long>, JpaSpecificationExecutor<StStudent> {

    List<StStudent> findAllByNameLikeAndSexLikeAndTypeIdLike(String name,String sex,Long typeId);

    List<StStudent> findAllByNameLikeAndSexLike(String name,String sex);

    @Transactional
    @Modifying
    @Query("delete from StStudent s where s.id in :ids")
    void deleteByIds(@Param("ids") List<Long> ids);

}